Repository navigation
[cp staging] Revert "Merge pull request #104155 from Krishna2323/krishna2323/issue-102277-expense-defaults" - #105888
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx bun ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
|
@MelvinBot review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@MelvinBot confirm #104155 was cleanly reverted |
|
Sorry fat finger |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
🤖 Web test steps verification results: Verified on dev NewDot web: the matching expense opened without crashing, Equipment applied automatically, and 12.34 USD remained unchanged. Preview showed the matching expense and deletion removed the rule; offline and console checks remain blocked.
view run · no recording available |
|
Not completely clean. The feature changes from Support expense defaults for more than just merchants are reversed. The later category-creation hook is preserved. However, the conflict resolution restores the entire old lint baseline, including unrelated suppressions (config/oxlint/oxlint.seatbelt.tsv:1434–1436). Keep the PR base’s baseline and restore only entries required by restored files. |
…323/issue-102277-expense-defaults" This reverts commit 5fe4be0, which added amount and tag conditions to expense default rules. Deploy blockers 105805, 105811, 105812, 105819 and 105862 all come from the amount condition. Reverting clears them while the rules engine work continues. The conflict in DynamicIOURequestStepCategoryCreate.tsx keeps main's version, because useCreateAndApplyCategory landed after this PR and is not being reverted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: krishna2323 <belivethatkg@gmail.com>
6d252e4 to
9f34259
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d252e47b3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| function getTaxExpenseRules(policy: OnyxEntry<Policy>): ExpenseRule[] { | ||
| return policy?.rules?.expenseRules?.filter((rule) => rule.tax) ?? []; |
There was a problem hiding this comment.
Migrate category defaults before switching back to policy storage
For a workspace that created a category-tax default while the parent version was live, that default was written as a SetRule in rules_; this resolver now reads only policy.rules.expenseRules, and this revert does not migrate or delete the existing record. Those defaults therefore disappear from category settings and the client tax lookup falls back to the workspace default, so affected expenses no longer get the configured category rate. Preserve the existing records in the lookup or migrate them before switching storage back.
Useful? React with 👍 / 👎.
| const hasCreateTransactionTrigger = getRuleTriggers(rule).some((trigger) => trigger === CONST.RULES.TRIGGERS.CREATE_TRANSACTION); | ||
| const hasSetAction = actions.some((action) => action?.name === CONST.RULES.ACTIONS.SET); | ||
| const hasCondition = getRuleFilterLeaves(rule.filters).length > 0; | ||
| const hasMerchantFilter = getRuleFilterLeaves(rule.filters).some((leaf) => leaf.left === CONST.RULES.EXPENSE_DEFAULT.FIELD.MERCHANT); |
There was a problem hiding this comment.
Keep saved merchantless rules reachable for cleanup
When a workspace saved a tag-only default while this feature was live, hasMerchantFilter is false, so isExpenseDefaultRule filters the persisted record out of getPolicyExpenseDefaultRules and the Expense defaults table. This revert sends no DeleteRule, so the backend rule can keep applying while the admin loses the row needed to inspect or delete it. Keep existing merchantless rules visible and read-only for removal, or clean them up during the rollback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed, and this is the one I'd act on. After the revert isExpenseDefaultRule requires a merchant filter, so a tag-only or category-only rule saved yesterday drops out of the table while the server record survives and may keep applying. Staging only, same reasoning as above.
@JS00001 should these merchantless rules_ records be deleted on staging? A rule that still applies but no admin can see is worse than one that is gone.
| value: key, | ||
| keyForList: key, | ||
| isSelected: key === selectedTaxRate, | ||
| isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, |
There was a problem hiding this comment.
Exclude disabled tax rates from the category picker
If a workspace has a disabled tax rate that is not pending deletion, this list still marks it selectable because isDisabled checks only pendingAction. Saving it writes a category default, but getSelectableCategoryTaxCode rejects disabled IDs and falls back to the workspace default, so the saved rate never applies. Use isSelectableTaxRate or otherwise mark disabled rates unavailable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not caused by this PR. That isDisabled line is byte for byte identical to the pre-#104155 version of this file, which has been in production for a while, and the revert restores it unchanged. Real bug, but it needs its own issue rather than riding along on a revert.
| const actions: string[] = []; | ||
| for (const {field, value} of summaryFields) { |
There was a problem hiding this comment.
Show persisted amount actions in rule summaries
For a merchant-scoped rule saved before this revert with an amount action, the row remains in getPolicyExpenseDefaultRules, but getMerchantRuleFormValues now declines it and this summary builder has no FIELD.AMOUNT case. The read-only row therefore omits the amount (and an amount-only rule appears empty) even though the stored rule can keep changing expenses. Retain a read-only summary for stored amount actions or migrate/remove those records.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Same root cause as 1 and 2: a revert orphans records written while the feature was live. Staging only. Adding a read-only summary path for amounts would mean keeping part of the reverted code, which defeats the point of the revert.
| "../../src/pages/workspace/rules/MerchantRules/ExpenseDefaultTypePage.tsx" "@typescript-eslint/no-deprecated/MenuItem" 1 | ||
| "../../src/pages/workspace/rules/MerchantRules/ImportedMerchantRulesPage.tsx" "rulesdir/no-onyx-loading-status" 1 | ||
| "../../src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx" "@typescript-eslint/no-deprecated/MenuItemWithTopDescription" 1 | ||
| "../../src/pages/workspace/rules/MerchantRules/MerchantRulePageBase.tsx" "rulesdir/no-onyx-loading-status" 1 |
There was a problem hiding this comment.
This line seems no longer needed
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-11-04.at.12.04.12.PM.mov |
|
🚧 JS00001 has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Cherry-picked to staging by https://github.com/blimpich in version: 9.5.31-2 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.5.31-4 🚀
Bundle Size Analysis (Sentry): |





This reverts commit 5fe4be0, which added amount and tag conditions to expense default rules.
Explanation of Change
Reverts #104155, which added three capabilities to expense default rules: matching on a tag, setting an amount, and creating a rule with no merchant at all.
Before that PR,
MerchantRulePageBaserequired a merchant to save or preview a rule, and a category could only narrow a merchant rule further. This revert restores that requirement, so an expense default rule once again matches on a merchant, optionally narrowed by a category, and sets any field except amount.Every blocker listed below either targets a field that no longer exists (105805, 105811, 105812, 105819, 105862) or a rule shape that can no longer be authored (105817, 105822, 105828, 105829, 105855, 105859). 105817 is worth calling out: its premise is "rule can be created without merchant", which is exactly the capability being reverted.
Two conflicts came up against current main and were resolved by hand:
src/pages/iou/request/step/DynamicIOURequestStepCategoryCreate.tsxkeeps main's version. The revert wanted to restore the inline create-and-apply block, but Offer to create the searched-for category when a category search has no results #105575 later replaced that with theuseCreateAndApplyCategoryhook, and that PR is not being reverted.config/oxlint/oxlint.seatbelt.tsvtakes the revert's entries, matching the files that come back.Two caveats for QA. 105822 and 105855 may still reproduce using a rule that matches on both a merchant and a category, since that shape still exists:
Neither is caused by this PR, and the client sends the correct filter tree in both cases, so if they still reproduce they need a backend fix rather than another revert.
Fixed Issues
$ #105805
$ #105811
$ #105812
$ #105817
$ #105819
$ #105822
$ #105828
$ #105829
$ #105855
$ #105859
$ #105862
PROPOSAL: N/A, revert of a deploy-blocking PR
Tests
Precondition: a Control workspace with Rules, Categories and Tags enabled.
Offline tests
QA Steps
Precondition: a Control workspace with Rules, Categories and Tags enabled.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Monosnap.screencast.2026-11-04.16-22-16.mp4